﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.TextEditor.Document;
//using HCCodeParser;

namespace ICSharpCode.MSSQLExtensions
{
    public class MSSQLFoldingStrategy : IFoldingStrategy
    {
//        private SourceFile m_SourceFile;

        //FoldValueList m_FoldValueList = new FoldValueList();
        //public MSSQLFoldingStrategy(ref SourceFile oSourceFile)
        //{
        //    m_SourceFile = oSourceFile;
        //}

        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            DateTime oBegin = DateTime.Now;
            List<ICSharpCode.TextEditor.Document.FoldMarker> list = new List<ICSharpCode.TextEditor.Document.FoldMarker>();
            return list;

            //m_SourceFile.Parse();

            //try
            //{

            //    foreach (HCCodeParser.CharParent.CharRegion oRegion in m_SourceFile.ScopeHashTable.Values)
            //    {
            //        if (oRegion.CharRegionType == HCCodeParser.CharParent.CharRegionType.Literal)
            //            continue;
            //        //if (oRegion.EndWordLength > 2) // begin case end end are word scopes.
            //        //    continue;
            //        if (oRegion.IsResolved())
            //        {
            //            int istartLineNo = document.GetLineNumberForOffset(oRegion.CharIdxStart);
            //            int iendLineNo = document.GetLineNumberForOffset(oRegion.CharIdxEnd);
            //            if (istartLineNo != iendLineNo)
            //            {
            //                //HCSocketToolsLib.HCSocketSender.Instance().SendUDPMessage(
            //                //    System.Reflection.MethodBase.GetCurrentMethod()
            //                //    , string.Format("Adding Scope {0}-{1}", istartLineNo, iendLineNo));

            //                list.Add(new FoldMarker(document, istartLineNo,
            //                    document.GetLineSegment(istartLineNo).Length,
            //                    iendLineNo, document.GetLineSegment(iendLineNo).Length - oRegion.EndWordLength));
            //            }
            //        }

            //    }
            //}
            //catch (Exception ex)
            //{
            //    HCSocketToolsLib.HCSocketSender.Instance().SendUDPMessage(
            //        System.Reflection.MethodBase.GetCurrentMethod()
            //        , string.Format("Exception {0}", ex.ToString()));
                 
            //}

            //#region old_code

            //#endregion

            //DateTime oEnd = DateTime.Now;
            ////HCSocketToolsLib.HCSocketSender.Instance().SendUDPMessage(
            ////    System.Reflection.MethodBase.GetCurrentMethod()
            ////    , string.Format("Update Foldings -{0}s {1}ms ", (oEnd - oBegin).Seconds, (oEnd - oBegin).TotalMilliseconds));

            //return list;
        }
    }
}
